/*
 * CountDownLatch.h
 *  CountDownLatch的主要作用是确保Thread中传进去的func真的启动了以后
 *  外层的start才返回
 *  Created on: 2021年4月5日
 *      Author: san
 */

#ifndef BASE_COUNTDOWNLATCH_H_
#define BASE_COUNTDOWNLATCH_H_

#include "Condition.h"
#include "Mutex.h"
#include "noncopyable.h"

namespace san {

class CountDownLatch : noncopyable{
public:
	explicit CountDownLatch(int count);
	void wait();
	void countDown();
	~CountDownLatch(){};

private:
	mutable MutexLock mutex_;
	Condition condition_;
	int count_;
};

} /* namespace san */

#endif /* BASE_COUNTDOWNLATCH_H_ */
